package com.asc {
import com.asc.common.identicalTo;
import com.asc.common.strictlyEquals;
import com.asc.exceptions.AbstractMethodError;

import flash.utils.getQualifiedClassName;

import org.flexunit.assertThat;
import org.flexunit.asserts.assertEquals;

/**
 * The ObjectTestCase is the base-class for all
 * Commons test classes.
 */
public class ObjectTestCase {


  
  public function ObjectTestCase() {
  }


  /**
   * Convenience method for throwing abstract method errors.
   * @param methodName the name of the method to declare
   * abstract
   */
  protected function throwAbstractMethodError(methodName:String) : void {
    throw new AbstractMethodError(methodName, getQualifiedClassName(this));
  }


  /**
   * Create a reference item whose methods and properties
   * can be compared to the actual item.
   * @return The reference item
   */
  public function get referenceItem(): * {
    throwAbstractMethodError("referenceItem()");
    return null;
  }

  /**
   * Create a new instance of an item to test
   * against the reference item
   * @return a new instance of the reference item
   */
  public function get testItem() : * {
    throwAbstractMethodError("testItem()");
    return null;
  }


  /**
   * Ensure that the reference item matches the test item
   */
  protected function verify() : void {
    assertThat(
      "Reference item did not match test item",
      referenceItem,
      strictlyEquals(testItem)
    )
  }

  [Test]
  public function itemEqualsSelf():void {
    const item:* = testItem
    if(item is Identifiable) {
      assertThat("equality should hold", item, strictlyEquals(item));
    }
    assertThat("equality should hold", item, identicalTo(item));
  }


  
}
}